package com.instasale.converters;

import com.instasale.models.Feature;
import com.instasale.services.FeatureService;
import org.springframework.core.convert.converter.Converter;

import java.util.Set;

public class StringToFeatureConverter implements Converter<String, Set<Feature>> {

    FeatureService featureService;

    public StringToFeatureConverter(FeatureService featureService) {
        this.featureService = featureService;
    }

    @Override
    public Set<Feature> convert(String s) {
        Integer[] ids = {Integer.parseInt(s)};
        return featureService.getByIds(ids);
    }
}
